/*!
 * Base JS lib for project bull.
 */
var Momo = {
  ajax: function(action, url, data, successFunc, errorFunc) {
    $.ajax(url, {
      data: data,
      dataType: 'json',
      type: 'POST',
      success: function(resp) {
        if (resp.err) {
          window.alert(action + '失败，' + resp.err);
          console && console.log(resp);
          return;
        }
        successFunc && successFunc(resp);
      }, error: function(error) {
        window.alert(action + '失败，' + error);
        console && console.log(error);
        errorFunc && errorFunc(error);
      }
    });
  },
  syncAjax: function(action, url, data, successFunc, errorFunc) {
    $.ajax(url, {
      data: data,
      dataType: 'json',
      type: 'POST',
      async: false,
      success: function(resp) {
        if (resp.err) {
          window.alert(action + '失败，' + resp.err);
          console && console.log(resp);
          return;
        }
        successFunc && successFunc(resp);
      }, error: function(error) {
        window.alert(action + '失败，' + error);
        console && console.log(error);
        errorFunc && errorFunc(error);
      }
    });
  },
};
